import JSEncrypt from 'jsencrypt'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey =
  'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC0hWuzbVjnKZAe37dri80T4SutHnjzKGgWy7H14V6vKkfJlGM9cptBmZ1xL2kW11jNuPw1NaaRRK4RLNA0UY6jehj0iBg5CewR7NFMgDRCPOzpvlziz1KChiPFZvj9/9jU9C9iGD/H/ijS/K/a5Ja65hvRlV91aWgHsWH/3HFLqwIDAQAB'

const privateKey =
  ''

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对需要加密的数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey)
  return encryptor.decrypt(txt)
}
